package com.android.View;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.android.GernerateKeySet.GenerateKeySet;
import com.android.GernerateKeySet.UserInformation;

public class RequisitionFormActivity extends Activity {
	@Override	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.requisition);
		
		
		Intent intent = getIntent();
		final String name = intent.getExtras().getString("uname");
		final String country = intent.getExtras().getString("ucountry");
		final String organization = intent.getExtras().getString("uorganization");
		final String location = intent.getExtras().getString("ulocation");
		final String email =  intent.getExtras().getString("uemail");
		final String password = intent.getExtras().getString("upassword");
		
		TextView txt = (TextView) findViewById(R.id.reqform);
		txt.setText("\n\n");
		txt.append("  Name : "+ name + "\n\n");
		txt.append("  Country : "+ country + "\n\n");
		txt.append("  OrgSanization : "+ organization + "\n\n");
		txt.append("  Location : "+ location + "\n\n");
		txt.append("  Email : "+ email + "\n\n");
		
		Button btnYes = (Button) findViewById(R.id.btnyes);
		Button btnNo = (Button) findViewById(R.id.btnno);		
		
		btnYes.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
				UserInformation info = new UserInformation();
				info.setCn(name);
				info.setCountry(country);
				info.setLocation(location);
				info.setOrganization(organization);
				info.setEmail(email);
				
				GenerateKeySet genKeySet = new GenerateKeySet();		
				
				Toast toast = new Toast(getApplicationContext());
				if(genKeySet.generateKey(info, password)){
					toast.makeText(getApplicationContext(), "인증서 발급을 완료하였습니다.", Toast.LENGTH_SHORT).show();

				}else {
					toast.makeText(getApplicationContext(), "인증서 발급에 실패하였습니다.", Toast.LENGTH_SHORT).show();
				}
			}
		});
		
		btnNo.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
			}
		});
		
		
		
		
	}
}
